﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using TupacAmaru.Yacep;
using TupacAmaru.Yacep.Extensions;

namespace Shura.Util.ExpressionParser
{
    /// <summary>
    /// 表达式解析帮助类,依赖yacep
    /// </summary>
    public static class ExpressionParse_Yacep<T>
    {
        private static IEvaluator Compile(string expression)
        {
            var result = expression.Compile();
            return result;
        }
        public static T Execute(string expression,object obj)
        {
            var evaluator = Compile(expression);
            var result = evaluator.EvaluateAs<T>(obj);
            return result;
        }
    }
}
